<!--用户的关系页面-->
<template>
  <el-card shadow="never" class="aui-card--fill">
    <div>
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item prop="exitId">
          <el-input v-model="dataForm.exitId" type="text" placeholder="请输入退出用户ID"></el-input>
        </el-form-item>
        <el-form-item prop="otherId">
          <el-input v-model="dataForm.otherId" type="text" placeholder="请输入平级用户ID"></el-input>
        </el-form-item>
        <el-form-item prop="userId">
          <el-input v-model="dataForm.userId" type="text" placeholder="请输入当前用户ID"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">查询</el-button>
        </el-form-item>
        <!--        <el-form-item>-->
        <!--          <el-button v-if="$hasPermission('api:userRelation:save')" type="primary"-->
        <!--                     @click="addOrUpdateHandle()">-->
        <!--            新增-->
        <!--          </el-button>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item>-->
        <!--          <el-button v-if="$hasPermission('api:userRelation:delete')" type="danger" @click="deleteHandle()">-->
        <!--            删除-->
        <!--          </el-button>-->
        <!--        </el-form-item>-->
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" stripe highlight-current-row
                @selection-change="dataListSelectionChangeHandle" @sort-change="dataListSortChangeHandle"
                style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
        <el-table-column prop="exitId" label="退出用户" header-align="center" align="center" width="">
          <template slot-scope="{}" slot="header">
            <!-- 表头名称 -->
            <span>退出用户</span>
            <el-tooltip class="item" effect="dark" placement="top">
              <i class="el-icon-question" style="font-size:16px;"></i>
              <!-- 悬停提示内容 -->
              <div slot="content">
                <div>点击下方名称查看用户详细信息</div>
              </div>
            </el-tooltip>
          </template>
          <template slot-scope="{row}">
            <el-tag size="small" type="primary" style="cursor: pointer;" @click="showUserList(row.exitUserDTO)" v-if="row.exitUserDTO">{{row.exitUserDTO.username}}</el-tag>
            <div v-if="!row.exitUserDTO">{{row.exitId}}</div>
          </template>
        </el-table-column>
        <el-table-column prop="otherId" label="平级用户" header-align="center" align="center" width="">
          <template slot-scope="{}" slot="header">
            <!-- 表头名称 -->
            <span>平级用户</span>
            <el-tooltip class="item" effect="dark" placement="top">
              <i class="el-icon-question" style="font-size:16px;"></i>
              <!-- 悬停提示内容 -->
              <div slot="content">
                <div>点击下方名称查看用户详细信息</div>
              </div>
            </el-tooltip>
          </template>
          <template slot-scope="{row}">
            <el-tag size="small" type="primary" style="cursor: pointer;" @click="showUserList(row.otherUserDTO)" v-if="row.otherUserDTO">{{row.otherUserDTO.username}}</el-tag>
            <div v-if="!row.otherUserDTO">{{row.otherId}}</div>
          </template>
        </el-table-column>
        <el-table-column prop="userId" label="当前用户" header-align="center" align="center" width="">
          <template slot-scope="{}" slot="header">
            <!-- 表头名称 -->
            <span>当前用户</span>
            <el-tooltip class="item" effect="dark" placement="top">
              <i class="el-icon-question" style="font-size:16px;"></i>
              <!-- 悬停提示内容 -->
              <div slot="content">
                <div>点击下方名称查看用户详细信息</div>
              </div>
            </el-tooltip>
          </template>
          <template slot-scope="{row}">
            <el-tag size="small" type="primary" style="cursor: pointer;" @click="showUserList(row.userDTO)" v-if="row.userDTO">{{row.userDTO.username}}</el-tag>
            <div v-if="!row.userDTO">{{row.userId}}</div>
          </template>
        </el-table-column>
        <el-table-column prop="relationType" label="用户关系" header-align="center" align="center" width="">
          <template slot-scope="{row}">
            <div>
              {{ $getDictLabel("relation_type", row.relationType) }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="createDate" label="创建日期" header-align="center" align="center"></el-table-column>
      </el-table>
      <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
                     layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
                     @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
      <!--查看用户信息组件-->
      <com-user-list :visible.sync="showUser" :content="content"></com-user-list>
    </div>

  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './userRelationAddOrUpdate.vue'
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/api/userRelation/page',
        getDataListIsPage: true,
        deleteURL: '/api/userRelation',
        deleteIsBatch: true
      },
      showUser:false,                   //是否显示用户信息
      content:{},                       //用户信息内容
      dataForm: {
        id: '',                         //id
        exitId:'',                      //退出用户ID
        otherId: '',                    //其他用户ID
        relationType:'',                //用户关系：0上级1平级
        userId:'',                      //用户ID
      },
    }
  },
  components: {
    AddOrUpdate
  },
  created() {

  },
  methods: {
    //显示用户信息
    showUserList(content){
      this.showUser=true;
      this.content= content;
    },
  }
}
</script>
